home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / laptop-mode < prev    next >
Encoding:
Text File  |  2006-12-06  |  1.8 KB  |  74 lines

  1. #!/bin/sh
  2. #
  3. # chkconfig: - 20 90
  4. # description: Starts and stops "laptop-mode" - tweaks system behavior
  5. #              to extend battery life.
  6. #
  7. # config:  /etc/laptop-mode/laptop-mode.conf
  8.  
  9. test -f /usr/sbin/laptop_mode || exit 0
  10.  
  11. . /lib/lsb/init-functions
  12.  
  13. if [ -f /etc/default/laptop-mode ]; then
  14.     . /etc/default/laptop-mode;
  15. fi
  16. if [ -f /etc/default/acpi-support ]; then
  17.     . /etc/default/acpi-support;
  18. fi
  19.  
  20. if [ x$ENABLE_LAPTOP_MODE = xfalse ]; then
  21.     exit 0;
  22. fi
  23.  
  24. # Enable laptop mode when the system is booted when running on battery.
  25.  
  26. case $1 in
  27.   start)
  28.     log_action_begin_msg "Enabling laptop mode"
  29.     touch /var/run/laptop-mode-enabled        
  30.     RESULT=$(/usr/sbin/laptop_mode auto init)
  31.     log_action_end_msg 0 "$RESULT"
  32.     ;;
  33.  
  34.   restart|reload|force-reload)
  35.     set -e
  36.     log_action_begin_msg "Stopping laptop mode"
  37.     
  38.     # Full restart: first stop laptop mode completely (to restore default mount options etc.)
  39.     rm -f /var/run/laptop-mode-enabled
  40.     RESULT=$(/usr/sbin/laptop_mode stop init)
  41.     log_action_end_msg 0 "$RESULT"
  42.     
  43.     # Now remove files containing stored status, re-enable, and start it up again.
  44.     rm -f /var/run/laptop-mode-*
  45.     touch /var/run/laptop-mode-enabled
  46.     log_action_begin_msg "Starting laptop mode"
  47.     RESULT=$(/usr/sbin/laptop_mode auto init force)
  48.     log_action_end_msg 0 "$RESULT"
  49.     ;;
  50.  
  51.   stop)
  52.     rm -f /var/run/laptop-mode-enabled
  53.     log_action_begin_msg "Disabling laptop mode"
  54.     RESULT=$(/usr/sbin/laptop_mode stop init)
  55.     if [ $? -ne 0 ]; then
  56.         log_action_end_msg 1 "$RESULT"
  57.     exit 1
  58.     fi
  59.     log_action_end_msg 0
  60.     ;;
  61.  
  62.   status)
  63.     echo "Laptop mode status:"
  64.     echo
  65.     /usr/sbin/laptop_mode status
  66.     ;;
  67.     
  68.   *)
  69.     echo "Usage: $0 {stop|start|restart|reload|force-reload|status}" >&2
  70.     exit 2
  71.     ;;
  72. esac
  73. exit 0
  74.